package com.anxin.registerManagement.controller;

import com.anxin.registerManagement.bean.persist.Comment;
import com.anxin.registerManagement.service.CommentService;
import com.anxin.registerManagement.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "评论接口")
@RestController
@RequestMapping("/comments")
public class CommentController {

    private static Logger logger = LoggerFactory.getLogger(CommentController.class);

    @Autowired
    CommentService commentService;

    @ApiOperation("添加评论")
    @PostMapping("/add")
    public ResultUtil addComment(@RequestBody Comment comment) {
        logger.info("添加评论：{}", comment);
        commentService.addComment(comment);
        return ResultUtil.success();
    }

    @ApiOperation("删除评论")
    @PostMapping("/delete")
    public ResultUtil deleteComment(@RequestParam("id") List<Integer> id) {
        logger.info("删除评论：{}", id);
        commentService.deleteComment(id);
        return ResultUtil.success();
    }
}
